package org.admanager.mapping.plugin.diagram.edit.policies;

import org.admanager.mapping.plugin.diagram.edit.commands.ComponentMappingCreateCommand;
import org.admanager.mapping.plugin.diagram.edit.commands.ComponentReferenceMappingCreateCommand;
import org.admanager.mapping.plugin.diagram.edit.commands.ComponentServiceMappingCreateCommand;
import org.admanager.mapping.plugin.diagram.edit.commands.CompositeMappingCreateCommand;
import org.admanager.mapping.plugin.diagram.edit.commands.DocumentRootCreateCommand;
import org.admanager.mapping.plugin.diagram.edit.commands.PatternCreateCommand;
import org.admanager.mapping.plugin.diagram.edit.commands.ReferenceMappingCreateCommand;
import org.admanager.mapping.plugin.diagram.edit.commands.ServiceMappingCreateCommand;
import org.admanager.mapping.plugin.diagram.providers.SOADManagementMetamodelElementTypes;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gef.commands.Command;
import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
import org.eclipse.gmf.runtime.emf.commands.core.commands.DuplicateEObjectsCommand;
import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.DuplicateElementsRequest;

/**
 * @generated
 */
public class RootMappingItemSemanticEditPolicy extends
		SOADManagementMetamodelBaseItemSemanticEditPolicy {

	/**
	 * @generated
	 */
	public RootMappingItemSemanticEditPolicy() {
		super(SOADManagementMetamodelElementTypes.RootMapping_1000);
	}

	/**
	 * @generated
	 */
	protected Command getCreateCommand(CreateElementRequest req) {
		if (SOADManagementMetamodelElementTypes.ComponentReferenceMapping_2010 == req
				.getElementType()) {
			return getGEFWrapper(new ComponentReferenceMappingCreateCommand(req));
		}
		if (SOADManagementMetamodelElementTypes.ComponentServiceMapping_2011 == req
				.getElementType()) {
			return getGEFWrapper(new ComponentServiceMappingCreateCommand(req));
		}
		if (SOADManagementMetamodelElementTypes.CompositeMapping_2012 == req
				.getElementType()) {
			return getGEFWrapper(new CompositeMappingCreateCommand(req));
		}
		if (SOADManagementMetamodelElementTypes.ComponentMapping_2013 == req
				.getElementType()) {
			return getGEFWrapper(new ComponentMappingCreateCommand(req));
		}
		if (SOADManagementMetamodelElementTypes.ServiceMapping_2014 == req
				.getElementType()) {
			return getGEFWrapper(new ServiceMappingCreateCommand(req));
		}
		if (SOADManagementMetamodelElementTypes.ReferenceMapping_2015 == req
				.getElementType()) {
			return getGEFWrapper(new ReferenceMappingCreateCommand(req));
		}
		if (SOADManagementMetamodelElementTypes.DocumentRoot_2016 == req
				.getElementType()) {
			return getGEFWrapper(new DocumentRootCreateCommand(req));
		}
		if (SOADManagementMetamodelElementTypes.Pattern_2017 == req
				.getElementType()) {
			return getGEFWrapper(new PatternCreateCommand(req));
		}
		return super.getCreateCommand(req);
	}

	/**
	 * @generated
	 */
	protected Command getDuplicateCommand(DuplicateElementsRequest req) {
		TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost())
				.getEditingDomain();
		return getGEFWrapper(new DuplicateAnythingCommand(editingDomain, req));
	}

	/**
	 * @generated
	 */
	private static class DuplicateAnythingCommand extends
			DuplicateEObjectsCommand {

		/**
		 * @generated
		 */
		public DuplicateAnythingCommand(
				TransactionalEditingDomain editingDomain,
				DuplicateElementsRequest req) {
			super(editingDomain, req.getLabel(), req
					.getElementsToBeDuplicated(), req
					.getAllDuplicatedElementsMap());
		}

	}

}
